import request from '@/utils/request';
import { time } from 'highcharts';

//设置安全员
export function setSafetyPeople(data) {
    return request({
        url: `/safety_officer/set/`,
        method: 'post',
        data:data
    })
}
//查看所有安全员
export function getSafetyPeople() {
  return request({
      url: `/safety_officer/all/`,
      method: 'get',
  })
}
//撤销安全员
export function delSafetyPeople(data) {
  return request({
      url: `/safety_officer/backout/`,
      method: 'post',
      data:data
  })
}

//创建风险管控
export function setRisk(data) {
  return request({
      url: `/risk_control/`,
      method: 'post',
      data:data
  })
}
//查看风险管控列表
export function loockRisk(date,data) {
  return request({
      url: `/risk_control/?start_time=${date.startDate}&end_time=${date.endDate}`,
      method: 'get',
      params:{
        size:data.pageSize,
        page:data.pageNum
      }
  })
}
//查看风险管控详情
export function loockRiskDetails(id) {
  return request({
      url: `risk_control/${id}/`,
      method: 'get',
  })
}
//修改风险管控
export function updataRiskDetails(id,data) {
  return request({
      url: `risk_control/${id}/`,
      method: 'put',
      data:data
  })
}
//删除风险管控
export function delRisk(id) {
  return request({
      url: `risk_control/${id}/`,
      method: 'delete',
  })
}
//文件上传风险管控
export function fileRisk(data) {
  return request({
      url: `/risk_control/file_create/`,
      method: 'post',
      data:data
  })
}

//上传附件2图片以外的其他文件
export function fileTwo(data) {
  return request({
      url: `/accessory_two/`,
      method: 'post',
      data:data
  })
}

//创建安全教育
export function setSafetyEducation(data) {
  return request({
      url: `/safety_education/`,
      method: 'post',
      data:data
  })
}
//查看安全教育列表
export function loockSafetyEducation(data,page) {
  return request({
      url: `/safety_education/`,
      method: 'get',
      params:{
        size:page.pageSize,
        page:page.pageNum,
        start_time:data.startDate,
        end_time:data.endDate,
        need_study:data.need_study,
        is_annual:data.is_annual,
        study_type:data.study_type
      }
  })
}
//文件上传安全教育试题
export function uploadSafetyEducation(data) {
  return request({
      url: `/safety_education/upload_file/`,
      method: 'post',
      data:data
  })
}
//删除安全教育
export function delSafetyEducation(id) {
  return request({
      url: `/safety_education/${id}/`,
      method: 'delete',
  })
}
//删除安全教育
export function afetyEducationDetails(id) {
  return request({
      url: `/safety_education/${id}/  `,
      method: 'get',
  })
}

//查看我可学习的安全教育列表
export function loockStudyEducation(data,page) {
  return request({
      url: `/safety_education/show/`,
      method: 'get',
      params:{
        size:page.pageSize,
        page:page.pageNum,
        start_time:data.startDate,
        end_time:data.endDate,
        need_study:data.need_study,
        is_annual:data.is_annual,
        study_type:data.study_type,
        type:data.type
      }
  })
}
//查看我可以学习的安全教育详情
export function loockStudyEducationDetails(id) {
  return request({
      url: `/safety_education/${id}/show_detail/`,
      method: 'get',
  })
}
//更新学习时间
export function updataStudyTime(id,time) {
  return request({
      url: `/safety_education/study/info/${id}/study_update/`,
      method: 'get',
      params:{
        time:time
      }
  })
}
//开启线上学习
export function openOnLine(id) {
  return request({
      url: `/safety_education/${id}/study_online/`,
      method: 'get',
  })
}
//开启线下学习
export function openOffLine(id) {
  return request({
      url: `/safety_education/study_offline/`,
      method: 'get',
      params:{
        id:id
      },
  })
}
//查看我的学习列表
export function myStudy(data,page) {
  return request({
      url: `/safety_education/study/info/my_study/`,
      method: 'get',
      params:{
        size:page.pageSize,
        page:page.pageNum,
        start_time:data.startDate,
        end_time:data.endDate,
        type:data.type
      },
  })
}
// 查看我的学习详情
export function myStudyDetail(id) {
  return request({
      url: `/safety_education/study/info/${id}/my_study_detail/`,
      method: 'get'
  })
}
// 开启考试
export function startExam(id) {
  return request({
      url: `/safety_education/study/info/${id}/start_exam/`,
      method: 'get'
  })
}
// 查看我的考试列表
export function myExam(data,page) {
  return request({
      url: `/safety_education/study/exam/my_exam/`,
      method: 'get',
      params:{
        size:page.pageSize,
        page:page.pageNum,
        start_time:data.startDate,
        end_time:data.endDate,
        type:data.type
      },
  })
}
// 查看我的学习详情
export function examDetail(id) {
  return request({
      url: `/safety_education/study/exam/${id}/my_exam_detail/`,
      method: 'get',
  })
}
//更新考试时间
export function updataExamTime(id,time) {
  return request({
      url: `/safety_education/study/exam/${id}/exam_update/`,
      method: 'get',
      params:{
        time:time
      }
  })
}
//考试结束
export function endExam(id,data) {
  return request({
      url: `/safety_education/study/exam/${id}/exam_end/`,
      method: 'post',
      data:{
        answer:data
      }
  })
}

//上传附件
export function file(data) {
  return request({
      url: `/accessory/`,
      method: 'post',
      data:data
  })
}